Skip to content

add sqlalchemy client pool configuration options via env vars#5751

Merged
adhami3310 merged 1 commit into
reflex-dev:mainfrom
benedikt-bartscher:sqla-pg-client-pool-config
Sep 5, 2025
Merged

add sqlalchemy client pool configuration options via env vars#5751
adhami3310 merged 1 commit into
reflex-dev:mainfrom
benedikt-bartscher:sqla-pg-client-pool-config

Conversation

@benedikt-bartscher

Copy link
Copy Markdown
Contributor

No description provided.

@codspeed-hq

codspeed-hq Bot commented Sep 1, 2025

Copy link
Copy Markdown

CodSpeed Performance Report

Merging #5751 will not alter performance

Comparing benedikt-bartscher:sqla-pg-client-pool-config (e237ddf) with main (39a07b6)

Summary

✅ 8 untouched benchmarks

@benedikt-bartscher benedikt-bartscher marked this pull request as ready for review September 1, 2025 16:44

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greptile Summary

This PR adds SQLAlchemy database connection pool configuration options to Reflex through environment variables. The changes introduce four new configurable parameters in the EnvironmentVariables class: SQLALCHEMY_POOL_SIZE (default 5), SQLALCHEMY_MAX_OVERFLOW (default 10), SQLALCHEMY_POOL_RECYCLE (default -1), and SQLALCHEMY_POOL_TIMEOUT (default 30). These environment variables are then consumed in the get_engine_args() function within model.py to configure both synchronous and asynchronous SQLAlchemy engines.

The implementation follows Reflex's existing pattern of using the EnvVar system for configuration management, allowing these database connection pool settings to be overridden via environment variables while providing sensible defaults that match SQLAlchemy's standard behavior. This enhancement enables production deployments to tune their database connection pools based on specific load characteristics, database server capabilities, and deployment environment constraints without requiring code modifications.

The changes integrate seamlessly with Reflex's existing database abstraction layer and maintain backward compatibility by using default values that preserve current behavior when the environment variables are not set.

Confidence score: 5/5

  • This PR is safe to merge with minimal risk as it only adds new configuration options with sensible defaults
  • Score reflects simple additive changes that follow established patterns and maintain backward compatibility
  • No files require special attention as the changes are straightforward and well-contained

2 files reviewed, no comments

Edit Code Review Bot Settings | Greptile

@adhami3310 adhami3310 merged commit 910e0c7 into reflex-dev:main Sep 5, 2025
40 of 41 checks passed
@larsblumberg

Copy link
Copy Markdown

Great guys! Does this fix my issue #5274?

@benedikt-bartscher

Copy link
Copy Markdown
Contributor Author

It seems like it does, sorry I did not see the issue. If you need more client options, feel free to let me know

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants